<?php
defined('BASEPATH') OR exit('No direct script access allowed');

class Welcome extends BaseController {

 public function __construct()
    {
        parent::__construct();
    }
	/**
	 * Index Page for this controller.
	 *
	 * Maps to the following URL
	 * 		http://example.com/index.php/welcome
	 *	- or -
	 * 		http://example.com/index.php/welcome/index
	 *	- or -
	 * Since this controller is set as the default controller in
	 * config/routes.php, it's displayed at http://example.com/
	 *
	 * So any other public methods not prefixed with an underscore will
	 * map to /index.php/welcome/<method_name>
	 * @see http://codeigniter.com/user_guide/general/urls.html
	 */
	public function index()
	{
		$redis = new redis();
        $redis->connect("127.0.0.1",6379);
//        $redis->flushAll();
//        $redis->LPUSH('user_id', 1);//(integer) 1
//        $redis->SET('user_name_1', 'admin');
//        $redis->SET('user_level_1',9999);
//
//        $redis->LPUSH('user_id', 2);//(integer) 2
//        $redis->SET('user_name_2', 'huangz');
//        $redis->SET('user_level_2', 10);
//
//        $redis->LPUSH('user_id', 59230);//(integer) 3
//        $redis->SET('user_name_59230','jack');
//        $redis->SET('user_level_59230', 3);
//
//        $redis->LPUSH('user_id', 222);  //(integer) 4
//        $redis->SET('user_name_222', 'hacker');
//        $redis->SET('user_level_222', 9999);
        $redis->EXISTS('user_info_sorted_by_level');  # 确保指定key不存在   //(integer) 0
        $redis_sort_option=array('BY'=>'user_level_*',
            'GET'=>array('#','user_name_*','user_password_*'),
            'STORE'=>'user_info_sorted_by_level'
        );
        var_dump($redis->SORT('user_id',$redis_sort_option));
        var_dump($redis->LRANGE('user_info_sorted_by_level', 0 ,11));
        //$redis->setex("baikai",200,"15624997040");
        var_dump($redis->get("baikai"));
        var_dump($redis->ttl("baikai"));
        die();
		//$a = $this->request->get('a');
		$this->load->view('welcome_message');
	}

}
